<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>login</title>

    <!-- core CSS -->
    <!--<link href="../css/bootstrap.css" rel="stylesheet">-->
    <link href="css/sai-theme.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="../../js/vendor/html5shiv.js"></script>
    <script src="../../js/vendor/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="container">

    <section class="panel panel-default col-md-6 col-sm-6">
        <div class="panel-heading">登录框</div>
        <div class="panel-body">

            <form role="form" class="form-horizontal">
                <div class="form-group">
                    <label class="col-md-2 col-sm-2 col-sm-2 control-label" for="empID">用户名</label>

                    <div class="col-md-10 col-sm-10 pr">
                        <input type="text" placeholder="请输入用户名" id="empID" class="form-control" maxlength="8">

                        <div class="tooltip input-tooltip-inline">
                            <div class="tooltip-inner label-danger hide">
                                账号不正确
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 col-sm-2 col-sm-2 control-label" for="empPwd">密码</label>

                    <div class="col-md-10 col-sm-10 pr">
                        <input type="password" placeholder="请输入密码" id="empPwd" class="form-control" maxlength="12">

                        <div class="tooltip input-tooltip-inline">
                            <div class="tooltip-inner label-danger hide">
                                密码错误
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-md-10 col-sm-10">
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="empRemember">记住账号与密码
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-md-10 col-sm-10 col-xs-10">
                        <button class="btn btn-primary" type="button" id="btnLogin" data-loading-text="正在登录...">登录</button>
                    </div>
                </div>
            </form>

        </div>
    </section>

</div>
<!-- /container -->


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery/jquery-1.11.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="lib/bmob.js"></script>
<script>

    $(function()
    {
        Bmob.initialize("9380b8fef6adad915286c53f0e0c3580","0a1523cbc7b6339582143a793c8c4cee");

        $('#btnLogin').click(function()
        {
            var $empID = $("#empID");
            var $empPwd = $("#empPwd");
            var tooltipInner = $empID.parent().find(".tooltip-inner");
            tooltipInner = $empPwd.parent().find(".tooltip-inner");
            if($empPwd.val().length < 6)
            {
                $empPwd.parent().removeClass("has-success").addClass("has-error");
                $empPwd.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $empPwd.parent().find(".tooltip-inner").text("密码长度不正确");
                $empPwd.focus();
                return;
            }
            else
            {
                $empPwd.parent().removeClass("has-error").addClass("has-success");
                tooltipInner.removeClass("label-danger").removeClass("hide").addClass("label-success");
                tooltipInner.text("密码长度正确");
            }

            var btn = $(this);
            btn.button('loading');
            
			    Bmob.User.logIn($empID.val(), $empPwd.val(), {
				  success: function(user) {
				    // Do stuff after successful login.
				    alert('login success')
				    user.isCurrent();
				    alert("      ");
				  },
				  error: function(user, error) {
				    // The login failed. Check error to see why.
				    alert(error.message);
				  }
				});
            
            setTimeout(function()
            {
                btn.button('reset');
            }, 2000);
        });

    });


</script>
</body>
</html>
